<script type="text/javascript">
	$(function(){
		$('#dg').edatagrid({
			url: 'store/list'
		});
	});
	function add() {
		window.location = '/store/new';
	}
	function edit() {
		var row = $('#dg').datagrid('getSelected');
		window.location = '/store/edit?id='+row.id;
	}
	function del() {
		var row = $('#dg').datagrid('getSelected');
		if(row) {
			$.messager.confirm('Thông báo','Bạn có chắc chắn muốn xóa?',function(r){
				if (r){
					$.ajax({
						url: 'store/delete?id=' + row.id,
						success: function() {
							$('#dg').datagrid('reload');
						}
					});
				}
			});
		}
	}
	function searchStore() {
		var kw = $('#kw').val();
		var d = $('input[name=date]').val();
		$('#dg').datagrid('load', {kw: kw, d: d});
	}
	
</script>
<!-- Begin Datagrid -->
<table id="dg" title="Quản lý kho" style="width: 100%;"
	toolbar="#toolbar" pagination="true" idField="id" rownumbers="true"
	fitColumns="false" singleSelect="true" nowrap="true"
	data-options="border:false,fit:true">
	<thead>
		<tr>
			<th field="username" width="120" sortable="true">Người nhập</th>
			<th field="description" width="150" sortable="true">Mô tả</th>
			<th field="created" width="150" sortable="true">Ngày</th>
			<th field="total" width="150" formatter="formatPrice">Tổng tiền</th>
		</tr>
	</thead>
</table>
<div id="toolbar" style="padding: 5px; height: auto;">
	<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
		onclick="add()">Thêm</a> <a href="#" class="easyui-linkbutton"
		iconCls="icon-edit" plain="true" onclick="edit()">Sửa</a> <a href="#"
		class="easyui-linkbutton" iconCls="icon-remove" plain="true"
		onclick="del()">Xóa</a>
	<!-- Begin Search -->
	<div id="search" style="padding: 3px">
		<span>Từ khóa:</span> <input id="kw" name="kw"
			style="line-height: 18px; border: 1px solid #ccc"> <span>Ngày:</span>
		<input id="date" name="date" class="easyui-datebox"
			style="line-height: 18px; border: 1px solid #ccc">
		<a href="#" class="easyui-linkbutton" iconCls="icon-search"
			plain="true" onclick="searchStore()">Tìm kiếm</a>
	</div>
	<!-- End Search -->
</div>
<!-- End DataGrid -->